<?php echo $this->fetch('header.html'); ?>
<?php echo $this->fetch('title.html'); ?>

<script type="text/javascript">
//注册表单验证
    $(function() {
        var vali=$('#register_form').validate({
            errorPlacement: function(error, element) {
                var error_td = element.parent('td');
                error_td.find('.field_notice').hide();
                error_td.append(error);
            },
            success: function(label) {
                label.addClass('validate_right').text('OK!');
            },
            onkeyup: false,
            rules: {
                user_name: {
                    required: true,
                    byteRange: [3, 15, '<?php echo $this->_var['charset']; ?>'],
                    remote: {
                        url: 'index.php?app=member&act=check_user&ajax=1',
                        type: 'get',
                        data: {
                            user_name: function() {
                                return $('#user_name').val();
                            }
                        },
                        beforeSend: function() {
                            var _checking = $('#checking_user');
                            _checking.prev('.field_notice').hide();
                            _checking.next('label').hide();
                            $(_checking).show();
                        },
                        complete: function() {
                            $('#checking_user').hide();
                        }
                    }
                },
                phone_mob: {
                    required: true,
                    number: true,
                    byteRange: [11, 11, '<?php echo $this->_var['charset']; ?>'],
                    remote: {
                        url: 'index.php?app=member&act=check_mobile&type=register',
                        type: 'get',
                        data: {
                            phone_mob: function() {
                                return $('#phone_mob').val();
                            }
                        },
                        beforeSend: function() {
                            var _checking = $('#checking_mobile');
                            _checking.prev('.field_notice').hide();
                            _checking.next('label').hide();
                            $(_checking).show();

                        },
                        complete: function() {

                            $('#checking_mobile').hide();
                        }
                    }
                },
                confirm_code: {
                    required: true,
                    number: true,
                    byteRange: [6, 6, '<?php echo $this->_var['charset']; ?>'],
                    remote: {
                        url: 'index.php?app=member&act=cmc&ajax=1',
                        type: 'get',
                        data: {
                            confirm_code: function() {
                                return $('#confirm_code').val();
                            }
                        },
                        beforeSend: function() {
                            var _checking = $('#checking_code');
                            _checking.next('label').hide();
                            $(_checking).show();

                        },
                        complete: function() {
                            $('#checking_code').hide();
                        }
                    }
                },
                password: {
                    required: true,
                    minlength: 6
                },
                password_confirm: {
                    required: true,
                    equalTo: '#password'
                },
                email: {
                    required: true,
                    email: true,
                    remote: {
                        url: 'index.php?app=member&act=check_email&ajax=1',
                        type: 'get',
                        data: {
                            email: function() {
                                return $('#email').val();
                            }
                        },
                        beforeSend: function() {
                            var _checking = $('#checking_user');
                            _checking.prev('.field_notice').hide();
                            _checking.next('label').hide();
                            $(_checking).show();
                        },
                        complete: function() {
                            $('#checking_user').hide();
                        }
                    }
                },
                captcha: {
                    required: true,
                    remote: {
                        url: 'index.php?app=captcha&act=check_captcha',
                        type: 'get',
                        data: {
                            captcha: function() {
                                return $('#captcha1').val();
                            }
                        }
                    }
                },
                agree: {
                    required: true
                }
            },
            messages: {
                user_name: {
                    required: '您必须提供一个用户名',
                    byteRange: '用户名必须在3-15个字符之间，中文占3个长度',
                    remote: '用户名不规范或者用户名已存在'
                },
                phone_mob: {
                    required: '手机号码必须输入',
                    number: '手机号码必须是数字',
                    byteRange: '手机号码长度必须为11位',
                    remote: '您提供的手机号码已存在,<a href="index.php?app=find_password">点击找回密码</a>'
                },
                confirm_code: {
                    required: '短信验证码不能为空',
                    number: '短信验证码必须是数字',
                    byteRange: '短信验证码必须为6位',
                    remote: '短信验证码错误'
                },
                password: {
                    required: '您必须提供一个密码',
                    minlength: '密码长度应在6-20个字符之间'
                },
                password_confirm: {
                    required: '您必须再次确认您的密码',
                    equalTo: '两次输入的密码不一致'
                },
                email: {
                    required: '您必须提供您的电子邮箱',
                    email: '这不是一个有效的电子邮箱',
                    remote: '邮箱已存在'
                },
                captcha: {
                    required: '请输入右侧图片中的文字',
                    remote: '验证码错误'
                },
                agree: {
                    required: '您必须阅读并同意该协议,否则无法注册'
                }
            }
        });
        
        
        

     
        var time = 60;
        var dtime = 60;
        $("#sendsms").bind('click', function() {
            if(!vali.element($("[name=phone_mob]"))){
                return;
            }
            var btn = $(this);
           
            var sendaddress = $('#phone_mob').val();
            var fhm = $("label[for='phone_mob']").text();
            if (fhm != '' && fhm != "OK!") {
                alert(lang.pls_enter_right_phone);
                return;
            }
             btn.attr("disabled","true");
            $.getJSON('index.php?app=member&act=send_code&type=register', {mobile: sendaddress}, function(result)
            {
                if (result.done == true) {
                    var hander = setInterval(function() {
                        if (time <= 0) {
                            canSend = true;
                            clearInterval(hander);
                            btn.val(lang.resend_msg);
                            btn.removeAttr("disabled");
                            time = dtime;
                        } else {
                            canSend = false;
                            btn.attr({
                                "disabled": "disabled"
                            });
                            btn.val(time + lang.after_minut_send);
                            time--;
                        }
                    },
                            1000);
                    alert(lang.msg_has_send + sendaddress + lang.pls_check_receive);
                    btn.removeAttr("disabled");
                } else {
                    alert(result.msg);
                    btn.removeAttr("disabled");
                }
            });
        });
    });
</script>



<div class="login_panel" >
    <form class="login_box" id="register_form" method="post">
        <table  width="100%">
            <tr>
                <td> <input placeholder="用户名" type="text" name="user_name" id="user_name" class="text">
                    <label class="field_notice"></label></td>
            </tr>
            <tr>  
                <td> <input placeholder="密码"  id="password" name="password" type="password"  class="text">  
                    <label class="field_notice"></label></td>
            </tr>
            <tr> 
                <td>  
                    <input placeholder="确认密码"   name="password_confirm" type="password"  class="text">  
                    <label class="field_notice"></label>
                </td>
            </tr>
            <?php if ($this->_var['msg_enabled']): ?>
            <tr> 
                <td>  
                    <input placeholder="手机" id="phone_mob"  name="phone_mob" type="text"  class="text">  
                    <label class="field_notice"></label>
                </td>
            </tr>
            <tr> 
                <td>  
                    <input type="button" id="sendsms" value="免费发送短信验证码"/>
                </td>
            </tr>
            <tr> 
                <td>  
                    <input placeholder="验证码" id="confirm_code"  name="confirm_code" type="text"  class="text">  
                    <label class="field_notice"></label>
                </td>
            </tr>
            <?php endif; ?>
            <tr> 
                <td>  
                    <input placeholder="电子邮箱" id="email"  name="email" type="text"  class="text">  
                    <label class="field_notice"></label>
                </td>
            </tr>
            <?php if ($this->_var['captcha']): ?>
            <tr>
                <td class="relative"><input type="text" name="captcha" class="text" id="captcha1" placeholder="请输入图片中的文字,点击图片以更换" />
                    <a href="javascript:change_captcha($('#captcha'));" class="renewedly"><img id="captcha" src="index.php?app=captcha&amp;<?php echo $this->_var['random_number']; ?>" /></a></td>
            </tr>
            <?php endif; ?>

            <tr>
                <td>
                    <input  value="立即注册"  type="submit" class="red_btn">
                </td>
            </tr>
        </table>
        <input type="hidden" name="ret_url" value="<?php echo $this->_var['ret_url']; ?>" />
        <p><a href="<?php echo url('app=member&act=login&ret_url=' . $this->_var['ret_url']. ''); ?>" >登录</a><a href="index.php?app=find_password&act=mobile" class="fr">手机找回密码</a></p>
        <input type="hidden"  checked name="agree" value="1" value="1" > 
    </form>
</div>


<?php echo $this->fetch('footer.html'); ?>